brightness = 3
blink = 0
speed = 0

while not Keys.newPress.Start do
  
  Controls.read ()
  
  startDrawing()
    
    screen.print (SCREEN_UP, 5, 5, "User Name : "..DS.UserName)
    screen.print (SCREEN_UP, 5, 15, "User Message : "..DS.UserMessage)
    screen.print (SCREEN_UP, 5, 25, "User Lang Number : "..DS.UserLangNum)
    screen.print (SCREEN_UP, 5, 35, "User Lang Name : "..DS.UserLangName)
    screen.print (SCREEN_UP, 5, 45, "User Color Number : "..DS.UserColorNum)
    screen.print (SCREEN_UP, 5, 55, "User Color Name : "..DS.UserColorName)
    screen.print (SCREEN_UP, 5, 65, "User Birth Month : "..DS.BirthMonth)
    screen.print (SCREEN_UP, 5, 75, "User Birth Day : "..DS.BirthDay)
    screen.print (SCREEN_UP, 5, 85, "Alarm Hour : "..DS.AlarmHour)
    screen.print (SCREEN_UP, 5, 95, "Alarm Min : "..DS.AlarmMin)
    screen.print (SCREEN_UP, 5, 105, "Is Lid Closed ? : "..tostring(DS.LidClosed))
    screen.print (SCREEN_UP, 5, 115, "Press UP to set screen up light ON.")
    screen.print (SCREEN_UP, 5, 125, "Press DOWN to set screen up light OFF.")
    screen.print (SCREEN_UP, 5, 135, "Press A to change the brightness (DSL only)")
    screen.print (SCREEN_UP, 5, 145, "Press B to start or stop the LED blink")
    screen.print (SCREEN_UP, 5, 155, "Press X to change the blink speed")
    
    if Keys.newPress.Up then
      DS.SetScreenLight (SCREEN_UP, LIGHT_ON)
    elseif Keys.newPress.Down then
      DS.SetScreenLight (SCREEN_UP, LIGHT_OFF)
    end
    
    if Keys.newPress.A then
      if brightness == 3 then
        brightness = 0
      else
        brightness = brightness + 1
      end
    end
    DS.SetDSLBrightness (brightness)
    
    if Keys.newPress.B then
      if blink == 0 then
        blink = 1
      else
        blink = 0
      end
    end
    
    if Keys.newPress.X then
      if speed == 0 then
        speed = 1
      else
        speed = 0
      end
    end
    DS.SetLedBlink (blink, speed)
    
  stopDrawing()
  
end

blink = nil
speed = nil
text = nil
brightness = nil
